package com.woniuxy03;

/**
 * @author 作者
 * @create 2025-07-22 16:26
 */
public class Student {
    //成员变量都是私有的
    private String name;
    private int age;


    //提供一组getXxx()  setXxx()
    public String getName(){
        return name;
    }

    public void setName(String name){
        this.name = name;
    }

    public int getAge(){
        return age;
    }

    public void setAge(int age){
        //正式的项目，setXxx()不会写逻辑代码，有专门的技术来做数据校验JSR303
        if (age>=18 && age<=60) {
            this.age = age;
        }else{
            age=18;
        }
    }

    public String showInfo(){
        return "name:"+name+",age:"+age;
    }
}
